<?php
header("Content-type: application/xml");
echo '<?xml version="1.0" encoding="'.$_s['encoding'].'"?>';
?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title><?php echo $_s['blogname'];?></title>
<link><?php echo $_s['base_url'];?></link>
<description></description>
<language>ru</language>
<?php
	$posts=getapts();
	if (empty($posts)) exit();
	rsort($posts);
	if (sizeof($posts) > $_s['rss_ppp']) $posts = array_slice($posts, $skip, $_s['rss_ppp']);
	for ($i = 0; $i< sizeof($posts); $i++)
	{
			$post = post_info($posts[$i]);

			if(@gbuffer($posts[$i],"close") || @gbuffer($posts[$i],"norss")) {
		//null
		} else {
		br();
		$link=generate_link('p='.$post['id']);
		#$text = preg_replace('/<cut>(.*)$/isU','<p><a href="'.$link.'">'.$_l['more'].'</a></p>',$post['text']);
		if(preg_match("#(.*)<cut text=\"(.*)\">#sU", $post['text'], $cut) or preg_match("#(.*)<cut>#sU", $post['text'], $cut))
			{
				if(isset($cut[2])) {
				$post['text'] = $cut[1].'<a href="'.generate_link('p='.$post['id']).'">'.$cut[2].'</a>';
				} else {
				$post['text'] = $cut[1].'<a href="'.generate_link('p='.$post['id']).'">'.$_l['more'].'</a>';
				}
			}
			$text=$post['text'];
		$title = htmlspecialchars($post['title'], ENT_QUOTES);
		$date = date("D, d M Y H:i:s ", $post['id'] + $_s['time_offset'] * 3600).'GMT';
?>
<item>
<title><?php echo $title;?></title>
<link><?php echo $link?></link>
<description><![CDATA[<?php echo $text;?>]]></description>
<pubDate><?php echo $date;?></pubDate>
</item>
<?php
	}
}
?>
</channel>
</rss>
<?php
 exit();
